package scau.mis4.chanyulin.atm.view;

import javafx.scene.control.TextArea;
import scau.mis4.chanyulin.atm.APP;
import scau.mis4.chanyulin.atm.base.utils.TimeUtils;

/**
 * Created by chanyulin on 2018/4/27.
 * 后台日志记录器图形
 */
public class LoggerView extends TextArea {

    public LoggerView() {
        this.setPrefSize(425, 225);
        this.setWrapText(true);
        this.setEditable(false);
        this.setFocusTraversable(false);
        // 修改样式
        this.setStyle(
            "-fx-text-fill: white;" +
            "-fx-highlight-text-fill: black;" +
            "-fx-highlight-fill: white;" +
            "-fx-control-inner-background:black;"
        );
    }

    /**
     * 添加日志
     * @param text
     */
    public void log(String text) {
        APP.ATM.log(text);
        this.appendText(TimeUtils.currentTime() + " " + text + "\n");
    }

    /**
     * 清空日志
     */
    public void clearAllLog() {
        this.clear();
    }

}
